import request from '@/utils/request'

export const getActivityList = (params) => {
  return request({
    url: '/activities',
    method: 'get',
    params
  })
}

export const getActivityDetail = (id) => {
  return request({
    url: `/activities/${id}`,
    method: 'get'
  })
}

export const createActivity = (data) => {
  return request({
    url: '/activities',
    method: 'post',
    data
  })
}

export const updateActivity = (id, data) => {
  return request({
    url: `/activities/${id}`,
    method: 'put',
    data
  })
}

export const deleteActivity = (id) => {
  return request({
    url: `/activities/${id}`,
    method: 'delete'
  })
}

export const enrollActivity = (id, data) => {
  return request({
    url: `/activities/${id}/enroll`,
    method: 'post',
    data
  })
}

export const cancelEnrollment = (id, data) => {
  return request({
    url: `/activities/${id}/cancel`,
    method: 'post',
    data
  })
}

export const completeActivity = (id) => {
  return request({
    url: `/activities/${id}/complete`,
    method: 'post'
  })
}

export const getUserEnrollments = (userId) => {
  return request({
    url: `/activities/user/${userId}/enrollments`,
    method: 'get'
  })
}

export const getActivityEnrollments = (id) => {
  return request({
    url: `/activities/${id}/enrollments`,
    method: 'get'
  })
}

export const approveEnrollment = (enrollmentId, data) => {
  return request({
    url: `/activities/enrollments/${enrollmentId}`,
    method: 'put',
    data
  })
}

export const checkIn = (id, data) => {
  return request({
    url: `/activities/${id}/checkin`,
    method: 'post',
    data
  })
}

export const checkOut = (id, data) => {
  return request({
    url: `/activities/${id}/checkout`,
    method: 'post',
    data
  })
}

export const checkMissingCheckOut = (id) => {
  return request({
    url: `/activities/${id}/check-missing-checkout`,
    method: 'post'
  })
}

